{{Extend "db/index"}}
{{Block "title"}}{{"修改数据"|T}}: {{Stored.table}} - {{Super}}{{/Block}}
{{Block "breadcrumb"}}
{{Super}}
<li><a href="{{dbMgrURL "listTable" Stored.dbName}}" data-pjax="#pcont" data-keepjs="true">{{"数据库"|T}}: {{Stored.dbName}}</a></li>
<li><a href="{{dbMgrURL "viewTable" Stored.dbName Stored.table}}" data-pjax="#pcont" data-keepjs="true">{{"表"|T}}: {{Stored.table}}</a></li>
<li class="active">{{"修改数据"|T}}</li>
{{/Block}}
{{Block "main"}}
<div class="row">
    <div class="col-md-12">
        {{Include "db/mysql/results"}}
        <div class="block-flat">
          <div class="content">
                <form class="form-horizontal group-border-dashed" method="POST" action="" id="form-edit-key">

      <div class="form-group">
          <label class="col-sm-2 control-label">{{"Key"|T}}</label>
          <div class="col-sm-9">
          <input class="form-control" type="text" name="key" value="{{Form "key"}}" id="value-key">
          </div>
      </div>
      <div class="form-group">
          <label class="col-sm-2 control-label">{{"TTL"|T}}</label>
          <div class="col-sm-9">
          <input class="form-control" type="text" name="ttl" value="{{Form "ttl"}}" id="value-ttl">
          </div>
      </div>
                <div class="form-group form-submit-group">
                  <div class="col-sm-9 col-sm-offset-2">
                    <input type="hidden" name="old" value="{{Form "key"}}">
                    <input type="hidden" id="ipt-old-ttl" name="oldTTL" value="{{Form "ttl"}}">
                    <button type="submit" class="btn btn-primary btn-lg"><i class="fa fa-save"></i> {{"保存"|T}}</button>
                    <a class="btn btn-default btn-lg" href="{{if Stored.table}}{{dbMgrURL "viewTable" Stored.dbName Stored.table}}{{else}}{{dbMgrURL "listTable" Stored.dbName}}{{end}}" data-pjax="#pcont" data-keepjs="true"><i class="fa fa-reply"></i> {{"返回"|T}}</a>
                  </div>
              </div>
                </form>
          </div><!-- /.content -->
        </div><!-- /.block-flat -->
    </div>
</div>
{{/Block}}

{{Block "footer"}}
{{Super}}

<script>
$(function(){
  $('#form-edit-key').on('submit',function(e){
      e.preventDefault();
      $.post(window.location.href,$(this).serializeArray(),function(r){
          if(r.Code==1) $('#ipt-old-ttl').val($('#value-ttl').val());
		App.message({text:r.Info,time:5000,sticky:false,class_name:r.Code==1?'success':'error'});
      },'json');
  });
});
</script>
{{/Block}}